package com.wanjl.mq.listener;


import lombok.extern.slf4j.Slf4j;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.stereotype.Component;

import java.time.LocalDateTime;

/**
 * @author WanJl
 * @version 1.0
 * @title SpringRabbitListener
 * @description 使用SpringAMQP进行监听，监听某个队列的所有消息
 * @create 2025/2/10
 */
@Slf4j
@Component
public class SpringRabbitListener {

    @RabbitListener(queues = "mdxq.hello")
    public void listenQueueMessage01(String message) throws InterruptedException {
        log.info("消费者01监听并接收到队列中的消息----->{}",message);
        Thread.sleep(20);
    }
    @RabbitListener(queues = "mdxq.hello")
    public void listenQueueMessage02(String message) throws InterruptedException {
        log.info("消费者02监听并接收到队列中的消息----->{}",message);
        Thread.sleep(2000);
    }
}
